<html><head><title>WebGadget</title></head>
<body bgcolor="#EFF1F0" link="#3A3966" vlink="#000000" alink="#000000">
<font face="Verdana, sans-serif" size="2"><p align="center"><b><font size="4">WebGadget()</font></b></p>
<p><b>Syntax</b></p><blockquote>
Result = <font color="#3A3966"><b>WebGadget</b></font>(#Gadget, x, y, Width, Height, URL$)</blockquote>

</blockquote>
<b>Description</b><br><blockquote>

Creates a Web gadget in the current GadgetList. It can display html pages. 

</blockquote><p><b>Parameters</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>#Gadget</i></td>
<td width="90%"> 
A number to identify the new gadget. <a href="../reference/purebasic_objects.html">#PB_Any</a> can 
be used to auto-generate this number. 

</td></tr>
<tr><td><i>x, y, Width, Height</i></td>
<td> 
The position and dimensions of the new gadget. 

</td></tr>
<tr><td><i>URL$</i></td>
<td> 
The url to load after the gadget is created. 

</td></tr>
</table>
</blockquote><p><b>Return value</b></p><blockquote>

Returns nonzero on success and zero on failure. If <font color="#924B72">#PB_Any</font> was used as the #Gadget parameter 
then the return-value is the auto-generated gadget number on success. 
<br>
<br>
This function fails if the required components for the WebGadget cannot be loaded. See below for the 
requirements for the WebGadget on each OS. 

</blockquote><p><b>Remarks</b></p><blockquote>

The following components are required to use the WebGadget on each OS. These components are required to use the 
WebGadget, not only for the compilation of the program. 
<br>
<br>
<b>Windows</b> 
<blockquote>

The WebGadget uses the Internet Explorer 4.0+ ActiveX object on Windows. 
</blockquote>


<b>Linux</b> 
<blockquote>

The WebGadget uses the WebKitGtk library on Linux. The package with this library is named 'libwebkit'. 
Some distributions may include an old version of this package which is named 'WebKitGtk'. 
If your distribution does not include a package for this library, the sources can be downloaded from the 
<a href="http://webkitgtk.org/">WebKitGtk home page</a>. 
</blockquote>


<b>Mac OSX</b> 
<blockquote>

The WebGadget uses the WebKit component on Mac OSX. This component comes with the operating system. There are no further requirements. 
</blockquote>


The following functions can be used to act on a WebGadget: 
<br>
<br>
- <a href="setgadgettext.html">SetGadgetText()</a>: Change the current URL. 
<br>
- <a href="getgadgettext.html">GetGadgetText()</a>: Get the current URL. 
<br>
- <a href="setgadgetstate.html">SetGadgetState()</a>: Perform an action on the gadget. The following constants are valid: 
<pre><font face="Courier New, Courier, mono"size="2">  <font color="#924B72">#PB_Web_Back</font>   : One step back in the navigation history.
  <font color="#924B72">#PB_Web_Forward</font>: One step forward in the navigation history.
  <font color="#924B72">#PB_Web_Stop</font>   : Stop loading the current page.
  <font color="#924B72">#PB_Web_Refresh</font>: Refresh the current page.
</font></pre>
<br>
<br>
- <a href="setgadgetitemtext.html">SetGadgetItemText()</a>: With <font color="#924B72">#PB_Web_HtmlCode</font> as 'Item' html code can be streamed into the Gadget. (Windows only) 
<br>

- <a href="getgadgetitemtext.html">GetGadgetItemText()</a>: The following constants can be used to get information  (Windows only): 
<pre><font face="Courier New, Courier, mono"size="2">  <font color="#924B72">#PB_Web_HtmlCode</font>     : Get the html code from the gadget.
  <font color="#924B72">#PB_Web_PageTitle</font>    : Get the current title for the displayed page.
  <font color="#924B72">#PB_Web_StatusMessage</font>: Get the current statusbar message.
  <font color="#924B72">#PB_Web_SelectedText</font> : Get the currently selected text inside the gadget.
</font></pre>

- <a href="setgadgetattribute.html">SetGadgetAttribute()</a>: Set the following attributes  (Windows only): 
<pre><font face="Courier New, Courier, mono"size="2">  <font color="#924B72">#PB_Web_ScrollX</font>       : Set the horizontal scrolling position.
  <font color="#924B72">#PB_Web_ScrollY</font>       : Set the vertical scrolling position.
  <font color="#924B72">#PB_Web_BlockPopups</font>   : Block popup windows. <font color="#924B72">#PB_EventType_PopupWindow</font> is fired if this setting is enabled.
  <font color="#924B72">#PB_Web_BlockPopupMenu</font>: Block standard the popup menu. <font color="#924B72">#PB_EventType_PopupMenu</font> is fired if this setting is enabled.
  <font color="#924B72">#PB_Web_NavigationCallback</font>: Set a callback for monitoring (and disabling) navigation.
</font></pre>

The Navigation callback must have the following format: 
<pre><font face="Courier New, Courier, mono"size="2">  <b><font color="#3A3966">Procedure</font></b> <font color="#3A3966">NavigationCallback</font>(Gadget, Url$)
    <font color="#3A3966">;</font>
    <font color="#3A3966">; Return #True to allow this navigation or #False to deny it.</font>
    <font color="#3A3966">;</font>
    <b><font color="#3A3966">ProcedureReturn</font></b> <font color="#924B72">#True</font>
  <b><font color="#3A3966">EndProcedure</font></b>
</font></pre>

- <a href="getgadgetattribute.html">GetGadgetAttribute()</a>: Get the following attributes  (Windows only): 
<pre><font face="Courier New, Courier, mono"size="2">  <font color="#924B72">#PB_Web_ScrollX</font>       : Get the horizontal scrolling position.
  <font color="#924B72">#PB_Web_ScrollY</font>?     : Get the vertical scrolling position.
  <font color="#924B72">#PB_Web_Busy</font>          : Returns nonzero if the gadget is busy loading a page.
  <font color="#924B72">#PB_Web_Progress</font>      : Returns the current (sometimes estimated) progress after a <font color="#924B72">#PB_EventType_DownloadProgress</font> event.
  <font color="#924B72">#PB_Web_ProgressMax</font>   : Returns the current (sometimes estimated) maximum progress after a <font color="#924B72">#PB_EventType_DownloadProgress</font> event.
  <font color="#924B72">#PB_Web_BlockPopups</font>   : Get the current popupwindow blocking setting.
  <font color="#924B72">#PB_Web_BlockPopupMenu</font>: Get the current popupmenu blocking setting.
  <font color="#924B72">#PB_Web_NavigationCallback</font>: Get the current navigation callback (if any).
</font></pre>

The following <a href="../window/eventtype.html">types of events</a> can happen for this gadget: 
<pre><font face="Courier New, Courier, mono"size="2">  <font color="#924B72">#PB_EventType_TitleChange</font>     : The page title changed (Windows only).
  <font color="#924B72">#PB_EventType_StatusChange</font>    : The status message changed (Windows only).
  <font color="#924B72">#PB_EventType_DownloadStart</font>   : A page download started  (Windows, OS X).
  <font color="#924B72">#PB_EventType_DownloadProgress</font>: Progress info is available with <a href="getgadgetattribute.html">GetGadgetAttribute()</a> (Windows only). 
  <font color="#924B72">#PB_EventType_DownloadEnd</font>     : A page download ended or aborted (Windows, OS X).
  <font color="#924B72">#PB_EventType_PopupWindow</font>     : A popup window was blocked (Windows only).
  <font color="#924B72">#PB_EventType_PopupMenu</font>       : The popup menu was blocked (display a custom menu here) (Windows only).
</font></pre>

</blockquote><p><b>Example</b></p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <b><font color="#3A3966">If</font></b> <font color="#3A3966">OpenWindow</font>(0, 0, 0, 600, 300, &quot;WebGadget&quot;, <font color="#924B72">#PB_Window_SystemMenu</font> | <font color="#924B72">#PB_Window_ScreenCentered</font>)
<font color="#3A3966">    WebGadget</font>(0, 10, 10, 580, 280, &quot;http://www.purebasic.com&quot;)
    <font color="#3A3966">; Note: if you want to use a local file, change last parameter to &quot;file://&quot; + path + filename</font>
    <b><font color="#3A3966">Repeat</font></b>
    <b><font color="#3A3966">Until</font></b> <font color="#3A3966">WaitWindowEvent</font>() = <font color="#924B72">#PB_Event_CloseWindow</font>
  <b><font color="#3A3966">EndIf</font></b>
</font></pre>
<br>
<p><img src="../HelpPictures/webgadget.png"></p>

<br>
<br>
Example 2: (with navigation callback) 
<pre><font face="Courier New, Courier, mono"size="2">  <font color="#3A3966">; This example does display the PureBasic.com website. Inside the callback procedure</font>
  <font color="#3A3966">; the navigation to the 'News' site will be avoided (#False returned), but allowed</font>
  <font color="#3A3966">; for all other sites (#True returned).</font>
    
  <b><font color="#3A3966">Procedure</font></b> <font color="#3A3966">NavigationCallback</font>(Gadget, Url$) 
    <b><font color="#3A3966">If</font></b> Url$= &quot;http://www.purebasic.com/news.php&quot; 
<font color="#3A3966">      MessageRequester</font>(&quot;&quot;, &quot;No news today!&quot;) 
      <b><font color="#3A3966">ProcedureReturn</font></b> <font color="#924B72">#False</font> 
    <b><font color="#3A3966">Else</font></b> 
      <b><font color="#3A3966">ProcedureReturn</font></b> <font color="#924B72">#True</font> 
    <b><font color="#3A3966">EndIf</font></b> 
  <b><font color="#3A3966">EndProcedure</font></b> 
  
  <b><font color="#3A3966">If</font></b> <font color="#3A3966">OpenWindow</font>(0, 0, 0, 600, 300, &quot;WebGadget&quot;, <font color="#924B72">#PB_Window_SystemMenu</font> | <font color="#924B72">#PB_Window_ScreenCentered</font>) 
<font color="#3A3966">    WebGadget</font>(0, 10, 10, 580, 280, &quot;http://www.purebasic.com&quot;) 
<font color="#3A3966">    SetGadgetAttribute</font>(0, <font color="#924B72">#PB_Web_NavigationCallback</font>, @NavigationCallback())
    <b><font color="#3A3966">Repeat</font></b> 
    <b><font color="#3A3966">Until</font></b> <font color="#3A3966">WaitWindowEvent</font>() = <font color="#924B72">#PB_Event_CloseWindow</font> 
  <b><font color="#3A3966">EndIf</font></b>
</font></pre>

</blockquote><p><b>See Also</b></p><blockquote>

<a href="getgadgettext.html">GetGadgetText()</a>, <a href="setgadgettext.html">SetGadgetText()</a>, <a href="getgadgetitemtext.html">GetGadgetItemText()</a>, <a href="setgadgetitemtext.html">SetGadgetItemText()</a>, <a href="setgadgetstate.html">SetGadgetState()</a>, 
<a href="getgadgetattribute.html">GetGadgetAttribute()</a>, <a href="setgadgetattribute.html">SetGadgetAttribute()</a> 

</Blockquote><p><b>Supported OS </b><Blockquote>All</Blockquote></p><center><- <a href=usegadgetlist.html>UseGadgetList()</a> - <a href="index.html">Gadget Index</a> - <a href="webgadgetpath.html">WebGadgetPath()</a> -><br><br>

</body></html>